package com.xingkeduo.pojo.utils;

import lombok.extern.slf4j.Slf4j;

import java.net.InetAddress;
import java.net.UnknownHostException;

/**
 * @Description:
 * @Author:gaozifeng
 * @Date 2019/7/13 16:23
 **/
@Slf4j
public class MpUtils {

    public static String devMpId = "xingkeduoceshi";
    private static String releaseMpId = "xingkeduozhengshi";

    private static String localIp = "192.168.31.253";


    public static String checkGetMpId(String active) {
        log.info("active[{}]",active);
        switch (active) {
            case "dev":
                if (localIp.equals(getIpAddress())) {
                    return "test";
                }
                return releaseMpId;
            case "alpha":
                return releaseMpId;
            case "pat":
                return releaseMpId;
            case "release":
                return releaseMpId;
            default:
                return null;
        }
    }

    public static String getIpAddress() {
        String ip = null;
        try {
            ip = InetAddress.getLocalHost().getHostAddress();
        } catch (UnknownHostException e) {
            e.printStackTrace();
        }
        return ip;
    }


}
